const { sequelize, syncDatabase } = require('../models');

async function initializeDatabase() {
  try {
    console.log('🚀 Starting database initialization...');
    
    // 测试数据库连接
    await sequelize.authenticate();
    console.log('✅ Database connection established successfully.');
    
    // 同步数据库结构
    await syncDatabase(false);
    console.log('✅ Database structure synchronized successfully.');
    
    console.log('🎉 Database initialization completed successfully!');
    process.exit(0);
  } catch (error) {
    console.error('❌ Database initialization failed:', error);
    process.exit(1);
  }
}

// 运行初始化
initializeDatabase();
